package com.second.app.thread.wait.o;

/**
 * @Author GYZ
 * <pre>
 *
 * </pre>
 */
public class WaitInterruptDemo {

    public static Object lock  = new Object();

    public static void main(String[] args) {
        Thread thread = new Thread(WaitInterruptDemo::doTestMethod, "线程A");

        thread.start();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        thread.interrupt();


    }

    private static void doTestMethod() {

        synchronized (lock){
            System.out.println("begin wait");
            try {
                lock.wait();

            } catch (InterruptedException e) {
                e.printStackTrace();
                System.out.println("because of exception, wait thread has been interrupted");
            }
            System.out.println("begin end ");
        }

    }
}
